<?php

require_once 'phpmoko/ui/HasAlignment.php';

/**
 * Base class for all PHPMoko drawable elements
 * We supose that every widget has its dimension
 * and it's aligned to any position.
 */
class Widget implements HasAlignment
{
	private $horizontal = null;
	private $vertical = null;
	protected $id = null;
	private $width = null;
	private $height = null;
	protected $style = null;
	private $visible = true;

	protected function __construct()
	{
		$this->vertical = HasVerticalAlignment::ALIGN_TOP;
	}

	/**
	 * (non-PHPdoc)
	 * @see ui/HasHorizontalAlignment#getHorizontalAlignment()
	 */
	public function getHorizontalAlignment()
	{
		return $this->horizontal;
	}

	/**
	 * (non-PHPdoc)
	 * @see ui/HasHorizontalAlignment#setHorizontalAlignment($align)
	 */
	public function setHorizontalAlignment($align)
	{
		$this->horizontal = $align;
	}

	/**
	 * (non-PHPdoc)
	 * @see ui/HasVerticalAlignment#getVerticalAlignment()
	 */
	public function getVerticalAlignment()
	{
		return $this->vertical;
	}

	/**
	 * (non-PHPdoc)
	 * @see ui/HasVerticalAlignment#setVerticalAlignment($align)
	 */
	public function setVerticalAlignment($align)
	{
		$this->vertical = $align;
	}

	public function setStyleName($style)
	{
		$this->style = $style;
	}

	public function addStyleName($style)
	{
		if ($this->style == null)
		{
			$this->setStyleName($style);
			return;
		}

		$this->style .= ' '.$style;
	}

	/**
	 * @param integer $id
	 *	Unique id for the widget
	 */
	public function setId($id)
	{
		$this->id = $id;
	}

	public function getId()
	{
		return $this->id;
	}
	
	public function toString()
	{
		return '';
	}

	public function setWidth($width)
	{
		$this->width = $width;
	}

	public function getWidth()
	{
		return $this->width;
	}

	public function setHeight($height)
	{
		$this->height = $height;
	}

	public function getHeight()
	{
		return $this->height;
	}

	public function setSize($width, $height)
	{
		$this->setWidth($width);
		$this->setHeight($height);
	}

	public function setVisible($visible)
	{
		$this->visible = $visible;
	}

	public function isVisible()
	{
		return $this->visible;
	}
}
?>